package com.dong.system.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 菜单表
 * </p>
 *
 * @author dongjian
 * @since 2021-01-23
 */
@Data
@Accessors(chain = true)
public class MenuVO implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "菜单/")
    private Long id;

    @ApiModelProperty(value = "上级菜单ID")
    private Long parentId;

    @ApiModelProperty(value = "菜单/按钮名称")
    private String menuName;

    @ApiModelProperty(value = "菜单URL")
    private String url;

    @ApiModelProperty(value = "权限标识")
    private String perms;

    @ApiModelProperty(value = "图标")
    private String icon;

    @ApiModelProperty(value = "类型 0目录 1菜单 2按钮")
    private String type;

    @ApiModelProperty(value = "排序")
    private Long orderNum;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    private Date modifiedTime;

    @ApiModelProperty(value = "0：不可用，1：可用")
    private Integer available;

    @ApiModelProperty(value = "0:不展开，1：展开")
    private Integer open;

    @ApiModelProperty(value = "叶子节点")
    private boolean leafNode;

    @ApiModelProperty(value = "根节点")
    private boolean rootNode;

    @ApiModelProperty(value = "叶子节点数据")
    private List<MenuVO> children;

    public void setChildren(List<MenuVO> children) {
        this.children = children;
        this.rootNode = this.parentId ==0;
        this.leafNode = children == null || children.size() == 0;
    }
}
